<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/Elektronicznysklep for the canonical source repository
 * @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Elektronicznysklep\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class ElektronicznysklepController extends AbstractActionController
{
    public function indexAction()
    {
        // grab the paginator from the Store Product
    	$ProductsTable = $this->getServiceLocator()->get('ProductsTable');
    	//$paginator = $this->getAlbumTable()->fetchAll(true);
    	$paginator = $ProductsTable()->fetchAll(true);
    	// set the current page to what has been passed in query string, or to 1 if none set
    	$paginator->setCurrentPageNumber((int) $this->params()->fromQuery('page', 1));
    	// set the number of items per page to 10
    	$paginator->setItemCountPerPage(10);
    	//throw new \Exception(var_dump($paginator));
    	return new ViewModel(array(	'paginator' => $paginator));
    	//return new ViewModel();
    }

    public function productDetailAction()
    {
    	$productId = $this->params()->fromRoute('id');
    	$productTable = $this->getServiceLocator()->get('ProductsTable');
    	$product = $productTable->getStore_products($productId);
    	 
    	$viewModel = new ViewModel(array('product' => $product,));
    	//return new ViewModel();
    	return $viewModel;
    }
    
    public function shoppingCartAction()
    {
    	return array();
    }
    public function fooAction()
    {
        // This shows the :controller and :action parameters in default route
        // are working when you browse to /elektronicznsklep/elektronicznsklep/foo
        return array();
    }
}
